package com.cat.enumerate;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/consecutive-numbers-sum/?envType=problem-list-v2&envId=enumeration
 * @create 2025/9/20 19:39
 * @since JDK17
 */

public class Solution04 {
    public int consecutiveNumbersSum(int n) {
        int ans = 0;
        n *= 2;
        for (int k = 1; k * k < n; k++) {
            if (n % k != 0) {
                continue;
            }
            if ((n / k - k + 1) % 2 == 0) {
                ans++;
            }
        }

        return ans;
    }
}
